﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Common;
using AspNetCs.Enumerations.Channel_Enum;
using AspNetCs.Enumerations.Up_Enum;

public partial class App_UploadFindFamily : BasePage
{
    protected string formobj = "", inputobj = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/UploadArticle.aspx", "请您登录", true);

        if (!Page.IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request["formobj"]))
            {
                formobj = Request["formobj"].ToString().Trim();
            }
            if (!string.IsNullOrEmpty(Request["inputobj"]))
            {
                inputobj = Request["inputobj"].ToString().Trim();
                ViewState["inputobj"] = inputobj;
            }
        }

        if (configInfo.IsUp == 0)
        {
            this.Button1.Text = "上传功能已关闭,你暂时不能上传任何图片";
            this.Button1.Enabled = false;
            Response.Write("上传功能已关闭,你暂时不能上传任何图片");
            Response.End();
        }
        if (Base_GetLoginInfo.GetUserID <= 0)
        {
            Response.Write("登录以后才能上传");
            Response.End();
        }


    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Cutter cut = new Cutter();

        cut.UpFoler = configInfo.UpFolder + Base_GetLoginInfo.GetUserID + "/FindFamily";
        cut.UpSize = configInfo.UpSize;
        //cut.FileIsCreate
        cut.IsNewFile = false;
        string Msg = "";
        bool isok = UpLoad_picture.UpSave(FileUpload1, cut, out Msg);
        if (!isok)
        {
            ShowMsgBack(Msg);
            Response.End();
        }
        else
        {
            Response.Write("<script>");
            Response.Write("alert(\"图片上传成功\");");
            if (ViewState["inputobj"] != null)
            {
                if (ViewState["inputobj"].ToString() != "")
                {
                    Response.Write("parent.window.document.getElementById('" + ViewState["inputobj"] + "').value='" + Msg + "';");
                }
            }
            Response.Write("parent.Wclose();</script>");
            Response.End();
        }

    }
}
